package com.example.lenovo.myapplication;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class WechatAdapter extends ArrayAdapter<pep> {

    private int resourceId;

    public WechatAdapter(Context context, int textViewResourceId, List<pep> objects) {
     super(context, textViewResourceId, objects);
     resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        pep p = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        ImageView pepImage = (ImageView) view.findViewById(R.id.we_image);
        TextView pepname = (TextView) view.findViewById(R.id.we_name);
        pepImage.setImageResource(p.getImageId());
        pepname.setText(p.getName());
        return view;
    }
}
